import { cookie } from 'vux'
// initial state
const state = {
  isLoading: true,
  userId: cookie.get('userId'),
  partnerId: cookie.get('partnerId'),
  batchId: cookie.get('batchId'),
  // isLogin: cookie.get('isLogin')
}
// getters
const getters = {
  isLoading: state => state.isLoading,
  userId: state => state.userId,
  partnerId: state => state.partnerId,
  batchId: state => state.batchId
}

// actions
const actions = {
  isLoading ({ commit, state }, isLoading) {
    state.isLoading = isLoading
  }
}
//
const SWITCH_IS_LOADING = 'SWITCH_IS_LOADING'
const SET_USER_ID = 'SET_USER_ID'
const SET_PARTNER_ID = 'SET_PARTNER_ID'
const SET_BATCH_ID = 'SET_BATCH_ID'
// const SET_IS_LOGIN = 'SET_IS_LOGIN'
// mutations
const mutations = {
  [SWITCH_IS_LOADING] (state, isLoading) {
    state.isLoading = isLoading
  },
  [SET_USER_ID] (state, userId) {
    state.userId = userId
  },
  [SET_PARTNER_ID] (state, partnerId) {
    state.partnerId = partnerId
  },
  [SET_BATCH_ID] (state, batchId) {
    state.batchId = batchId
  },
  // [SET_IS_LOGIN] (state, isLogin) {
  //   state.isLogin = isLogin
  // }
}

export default {
  state,
  getters,
  actions,
  mutations
}
